export const formConf = {
  formRef: "formRef",
  formModel: "formData",
  size: "default",
  labelPosition: "right",
  labelWidth: 100,
  formRules: "rules",
  gutter: 15,
  disabled: false,
  span: 24,
  formBtns: true,
};
/**
 * 文章配置组件
 * typeId: 1, 一级标题
 * typeId: 2, 二级标题
 * typeId: 3,图片
 * typeId: 4,文字
 */

const uploadImgUrl = import.meta.env.VITE_APP_BASE_API + "/file/upload"; // 上传的图片服务器地址
//类型 1一级标题 2二级标题 3图片 4文字
export const typeIdEnum = {
  topTitle: 1,
  secondTitle: 2,
  picture: 3,
  text: 4,
};

export const articleConfigObjectComponents = {
  1: {
    typeId: 1,
    label: "一级标题",
    tag: "el-input",
    tagIcon: "input",
    type: "text",
    placeholder: "请输入",
    defaultValue: undefined,
    span: 24,
    labelWidth: null,
    style: { width: "100%" },
    clearable: true,
    prepend: "",
    append: "",
    "prefix-icon": "",
    "suffix-icon": "",
    maxlength: null,
    "show-word-limit": false,
    readonly: false,
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: "https://element-plus.org/zh-CN/component/input",
    rules: [
      {
        required: true,
        message: "请输入一级标题",
      },
    ],
  },
  3: {
    typeId: 3,
    label: "上传",
    tag: "el-upload",
    tagIcon: "upload",
    action: uploadImgUrl,
    defaultValue: null,
    labelWidth: null,
    disabled: false,
    required: true,
    accept: "",
    name: "file",
    "auto-upload": true,
    showTip: false,
    buttonText: "点击上传",
    fileSize: 2,
    sizeUnit: "MB",
    "list-type": "text",
    multiple: false,
    regList: [],
    changeTag: true,
    document: "https://element-plus.org/zh-CN/component/upload",
    tip: "只能上传不超过 2MB 的文件",
    style: { width: "100%" },
    rules: [
      {
        required: true,
        message: "请上传图片",
      },
    ],
  },
  4: {
    typeId: 4,
    label: "多行文本",
    tag: "el-input",
    tagIcon: "textarea",
    type: "textarea",
    placeholder: "请输入",
    defaultValue: undefined,
    span: 24,
    labelWidth: null,
    autosize: {
      minRows: 4,
      maxRows: 4,
    },
    style: { width: "100%" },
    maxlength: null,
    "show-word-limit": false,
    readonly: false,
    disabled: false,
    required: true,
    rules: [
      {
        required: true,
        message: "请输入多行文本",
      },
    ],
    regList: [],
    changeTag: true,
    document: "https://element-plus.org/zh-CN/component/input",
  },
};
export const articleConfigComponents = Object.values(articleConfigObjectComponents);

// 组件rule的触发方式，无触发方式的组件不生成rule
export const trigger = {
  "el-input": "blur",
  "el-input-number": "blur",
  "el-select": "change",
  "el-radio-group": "change",
  "el-checkbox-group": "change",
  "el-cascader": "change",
  "el-time-picker": "change",
  "el-date-picker": "change",
  "el-rate": "change",
};

export const defaultArticleConfig = [
  {
    typeId: 1,
    label: "一级标题",
    tag: "el-input",
    tagIcon: "input",
    type: "text",
    placeholder: "请输入",
    defaultValue: undefined,
    span: 24,
    labelWidth: null,
    style: { width: "100%" },
    clearable: true,
    prepend: "",
    append: "",
    "prefix-icon": "",
    "suffix-icon": "",
    maxlength: null,
    "show-word-limit": false,
    readonly: false,
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: "https://element-plus.org/zh-CN/component/input",
  },
];
